<?php
require 'db.php';
if(isset($_POST['magv']))$magv=$_POST['magv'];
if(isset($_POST['nienkhoa']))$nienkhoa=$_POST['nienkhoa'];
if(isset($_POST['del'])){
	if(isset($_POST['mamh']))$mamh=$_POST['mamh'];
	$sql = "DELETE FROM dbo_kehoachhoithao WHERE nienkhoa=? and mamh=?";
	$stmt = $db->prepare ( $sql );
	$stmt->bindParam ( "1", $nienkhoa );
	$stmt->bindParam ( "2", $mamh );
	$stmt->execute ();
	$success=$stmt->rowCount();
	if(!$success){
		echo "Có lỗi xảy ra vui lòng thử lại sau ";
		exit;
	}else{
		echo 1;
		exit;
	}
}
$sql="SELECT dbo_monhoc.MaMH, TenMH, NienKhoa FROM dbo_kehoachhoithao, dbo_monhoc ";
$sql.=" WHERE dbo_kehoachhoithao.MaMH=dbo_monhoc.MaMH and NienKhoa=:nk  ";
$stmt = $db->prepare($sql);
$stmt->bindParam(":nk",$nienkhoa,PDO::PARAM_STR);
$stmt->execute();


$sql3="SELECT dbo_giangvien.MaGV,Holot, Ten FROM dbo_giangvien WHERE dbo_giangvien.MaGV=:magv";
$stmt2 = $db->prepare($sql3);
$stmt2->bindParam(":magv",$magv,PDO::PARAM_STR);
$stmt2->execute();
$r3=$stmt2->fetch();

?>
<hr ></hr>

<table  class="table table-bordered table-hover" style="font-size: 13px;">
	
			<thead>
				<div class="row">
				<div class="col-md-12 text-center">
				<p class="form-group alert-info"><label>MSGV :</label><span><?php echo $r3['MaGV'];?></span> <label><?php echo "  -  "?>Họ và tên :</label><span><?php echo $r3['Holot']." ".$r3['Ten'];?></span>
			</p> </div></div>
			<tr class="info"><th>STT</th><th>Mã môn thi</th><th>Tên môn thi</th><th>Năm học</th><th>Xóa</th></tr></thead>
			<tbody>
	<?php $i=1;
		if($stmt->execute()){		
			while($r=$stmt->fetch()){
?>
				<tr>
					<td><?php echo $i++;?></td>
					<td><?php echo $r['MaMH'];?></td>
					<td><?php echo $r['TenMH'];?></td>
					<td><?php echo $r['NienKhoa'];?></td>
	<td><a class="del" id="btnxoakhht" href='#' data-mamon="<?php echo $r['MaMH'];?>" data-tenmon="<?php echo $r['TenMH'];?>" ><span class="glyphicon glyphicon-trash"></span></a></td>
		<?php }} ?>	
			</tbody>
			</table>